package com.idione.util;

import java.io.InputStream;
import java.net.URL;

import android.content.Context;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public abstract class LogUtil {

	public static final boolean activitiesLog = true;
	public static final boolean controllerLog = true;
	public static final boolean modelLog = true;
	public static final boolean utilLog = true;

	public static Typeface getTypeFaceButton(Context context) {
		return Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Black.ttf");
	}
	
	public static Typeface getTypeFaceTitle(Context context) {
		return Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Condensed.ttf");
	}
	
	public static Typeface getTypeFaceSubtitle(Context context) {
		return Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-LightItalic.ttf");
	}
	
	public static Typeface getTypeFaceNumber(Context context) {
		return Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-MediumItalic.ttf");
	}
	
	public static Typeface getTypeFaceParagraph(Context context) {
		return Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Light.ttf");
	}
	
	public static Drawable LoadImageFromWebOperations(String url) {
	    try {
	    	URL url2 = new URL(url);
	        InputStream is = (InputStream) url2.getContent();
	        Drawable d = Drawable.createFromStream(is, "src name");
	        return d;
	    } catch (Exception e) {
	        return null;
	    }
	}
	
	public static boolean isNetworkAvailable(Context context) {
	    ConnectivityManager connectivityManager 
	          = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
	    NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
	    return activeNetworkInfo != null;
	}
}
